import numpy as np
import math
from PyCmpltrtok.common import sep
from PyCmpltrtok.common_3d import get_xyz, get_chunk, get_slice_of_sparse_xyz

scale = 1.0
N = 32
t = np.linspace(0, 10*(N-1), N, dtype=np.float32)
X, Y, Z = np.meshgrid(t, t, t, sparse=False, indexing='ij')
Xs, Ys, Zs = np.meshgrid(t, t, t, sparse=True, indexing='ij')
print('X', X.shape)
print('Y', Y.shape)
print('Z', Z.shape)
print('Xs', Xs.shape)
print('Ys', Ys.shape)
print('Zs', Zs.shape)

sn_x0, sn_x1 = 0, 4
sn_y0, sn_y1 = 4, 7
sn_z0, sn_z1 = N-2, N + 3

sep('Dense')
xx, yy, zz = X[sn_x0:sn_x1, sn_y0:sn_y1, sn_z0:sn_z1], Y[sn_x0:sn_x1, sn_y0:sn_y1, sn_z0:sn_z1], Z[sn_x0:sn_x1, sn_y0:sn_y1, sn_z0:sn_z1]
sep('xx')
print(xx)
sep('yy')
print(yy)
sep('zz')
print(zz)

sep('sparse')
res = get_slice_of_sparse_xyz(sn_x0, sn_x1, sn_y0, sn_y1, sn_z0, sn_z1, Xs, Ys, Zs)
print(res)
